﻿using System;
using System.Windows.Controls;
using System.Windows.Input;
using PengSW.Script;

namespace PengSW_ScriptUi
{
    /// <summary>
    /// TriggerScriptEditUi.xaml 的交互逻辑
    /// </summary>
    public partial class TriggerScriptEditUi : UserControl
    {
        public TriggerScriptEditUi()
        {
            InitializeComponent();
        }

        private TriggerScript Target => DataContext as TriggerScript;

        private void OnCompile_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                Target.Compile();
            }
            catch
            {
            }
        }

        private void OnCompile_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !string.IsNullOrWhiteSpace(Target?.Script);
        }
    }
}
